import axios from 'axios';

const http = axios.create({
    baseURL: '/api',
    timeout: 10000,
});
const token = process.env.VUE_APP_TOKEN;
http.interceptors.request.use(
    (config) => {
        config.headers['my-token'] = token;
        return config;
    },
    (reject) => {
        return Promise.reject(reject);
    }
);
http.interceptors.response.use(
    (res) => {
        console.log('res:', res);
        if (res.status === 200) {
            return Promise.resolve(res.data);
        }
    },
    (err) => {
        return Promise.reject(err);
    }
);

export default http;
